package hot100;

public class searchMatrix1 {
    public boolean searchMatrix(int[][] matrix, int target) {
        for(int[] row : matrix) {
            int ret = search(row,target);
            if( ret >= 0) {
                return true;
            }
        }
        return false;

    }

    public int search(int[] nums,int target) {
        int l = 0;
        int r = nums.length - 1;
        while(l <= r) {
            int mid = l + (r - l) / 2;
            if(nums[mid] == target) {
                return mid;
            }else if(nums[mid] > target) {
                r = mid - 1;
            }else {
                l = mid + 1;
            }
        }
        return -1;
    }
}
